---
import type { CollectionEntry } from 'astro:content'

import { getCollection, render } from 'astro:content'

import ContentLayout from '../../../layouts/Content.astro'

type Props = CollectionEntry<'rules'>

let rule = Astro.props

let { headings, Content } = await render(rule)

export async function getStaticPaths() {
  let rules = await getCollection('rules')
  return rules.map(currentRule => ({
    params: {
      slug: currentRule.id,
    },
    props: currentRule,
  }))
}
---

<ContentLayout
  path={[
    {
      href: '/rules',
      name: 'Rules',
    },
    {
      href: `/rules/${rule.id}`,
      name: rule.data.title,
    },
  ]}
  editLink={`https://github.com/azat-io/eslint-plugin-perfectionist/tree/main/docs/content/rules/${rule.id}.mdx`}
  {headings}
  {...rule.data}
>
  <h1>{rule.data.title}</h1>
  <Content />
</ContentLayout>
